<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../script/bootstrap-3.3.7.min.css">
    <script src="../script/jquery-1.10.min.js"></script>

</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <p style="color: red;font-size: 1.5em;"></p>
        </div>
    </div>
    <div class="row">

    </div>
    <div class="row">
        <div class="col-md-6 ">
            <div>
                <textarea id="text1" rows="10" cols="50"></textarea>
                <script>
                    str = 'arr = [1,2,3];\n' +
                        ' if(arr instanceof Array){ \n' +
                        '   document.getElementById("demo2").innerHTML("arr 是一个数组");\n' +
                        '} else {\n' +
                        '  document.getElementById("demo2")("arr 不是一个数组");\n' +
                        '  }'
                    document.getElementById("text1").value = str
                </script>

            </div>
            <div>
                <p style="font-size: 1.5em;color: red">instanceof 返回布尔值，如果是指定类型返回 true，否则返回 false。</p>
                <p id="demo1"></p>
            </div>
        </div>
        <div class="col-md-6 ">

            <div>
                <textarea id="text2" rows="10" cols="50"></textarea>
                <script>
                    str = ' $("#demo1").text(typeof("abc") +" "+\n' +
                        'typeof(3.14) + " "+\n' +
                        'typeof(function () {}) + " "\n' +
                        ')'
                    document.getElementById("text2").value = str
                </script>

            </div>
            <div>
                <p id="demo2"></p>
                <p style="font-size: 1.5em;color: red"> typeof 操作符返回变量、对象、函数、表达式的类型。</p>

            </div>
        </div>
    </div>
    <p class="page-header"></p>
    <div class="row">
        <div>
            <textarea id="text3" rows="10" cols="50"></textarea>
            <script>
                str = 'document.getElementById("demo").innerHTML = \n' +
                    '    "john".constructor + "<br>" +\n' +
                    '    (3.14).constructor + "<br>" +\n' +
                    '    false.constructor + "<br>" +\n' +
                    '    [1,2,3,4].constructor + "<br>" +\n' +
                    '    {name:\'john\', age:34}.constructor + "<br>" +\n' +
                    '    new Date().constructor + "<br>" +\n' +
                    '    function () {}.constructor;'
                document.getElementById("text3").value = str
            </script>

        </div>
        <p style="font-size: 1.5em;color: red"> constructor 属性返回变量或对象的构造函数。</p>
        <p id="demo3"></p>
    </div>
</div>
<p class="page-header"></p>
<script>

    $("#demo2").text(typeof("abc") + " " +
        typeof(3.14) + " " +
        //        typeof(NaN) + "<br>" +
        //        typeof(false) + "<br>" +
        //        typeof([1,2,3,4]) + "<br>" +
        //        typeof({name:'john', age:34}) + "<br>" +
        //        typeof(new Date()) + "<br>" +
        typeof(function () {
        }) + " "
//        typeof(myCar) + "<br>" +
//        typeof(null)
    )

    function instancec() {
        arr = [1, 2, 3];
        if (arr instanceof Array) {
            document.getElementById("demo1").innerHTML="arr 是一个数组";
        } else {
            document.getElementById("demo1").innerHTML="arr 不是一个数组";
        }
    }
    instancec()

    document.getElementById("demo3").innerHTML =
        "john".constructor + "<br>" +
        (3.14).constructor + "<br>" +
        false.constructor + "<br>" +
        [1, 2, 3, 4].constructor + "<br>" +
        {name: 'john', age: 34}.constructor + "<br>" +
        new Date().constructor + "<br>" +
        function () {
        }.constructor;

</script>

</body>
</html>